package com.ruoyi.buss.grid.sq.service.impl;

import java.util.List;

import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.buss.grid.sq.mapper.DataWgWgsqSqMapper;
import com.ruoyi.buss.grid.sq.domain.DataWgWgsqSq;
import com.ruoyi.buss.grid.sq.service.IDataWgWgsqSqService;

/**
 * 网格社区按社区维度统计Service业务层处理
 * 
 * @author sxy
 * @date 2021-07-16
 */
@Service
public class DataWgWgsqSqServiceImpl implements IDataWgWgsqSqService 
{
    @Autowired
    private DataWgWgsqSqMapper dataWgWgsqSqMapper;

    /**
     * 查询网格社区按社区维度统计
     * 
     * @param id 网格社区按社区维度统计ID
     * @return 网格社区按社区维度统计
     */
    @Override
    public DataWgWgsqSq selectDataWgWgsqSqById(String id)
    {
        return dataWgWgsqSqMapper.selectDataWgWgsqSqById(id);
    }

    /**
     * 查询网格社区按社区维度统计列表
     * 
     * @param dataWgWgsqSq 网格社区按社区维度统计
     * @return 网格社区按社区维度统计
     */
    @Override
    public List<DataWgWgsqSq> selectDataWgWgsqSqList(DataWgWgsqSq dataWgWgsqSq)
    {
        return dataWgWgsqSqMapper.selectDataWgWgsqSqList(dataWgWgsqSq);
    }

    /**
     * 新增网格社区按社区维度统计
     * 
     * @param dataWgWgsqSq 网格社区按社区维度统计
     * @return 结果
     */
    @Override
    public int insertDataWgWgsqSq(DataWgWgsqSq dataWgWgsqSq)
    {
        return dataWgWgsqSqMapper.insertDataWgWgsqSq(dataWgWgsqSq);
    }

    /**
     * 修改网格社区按社区维度统计
     * 
     * @param dataWgWgsqSq 网格社区按社区维度统计
     * @return 结果
     */
    @Override
    public int updateDataWgWgsqSq(DataWgWgsqSq dataWgWgsqSq)
    {
        return dataWgWgsqSqMapper.updateDataWgWgsqSq(dataWgWgsqSq);
    }

    /**
     * 批量删除网格社区按社区维度统计
     * 
     * @param ids 需要删除的网格社区按社区维度统计ID
     * @return 结果
     */
    @Override
    public int deleteDataWgWgsqSqByIds(String[] ids)
    {
        return dataWgWgsqSqMapper.deleteDataWgWgsqSqByIds(ids);
    }

    /**
     * 删除网格社区按社区维度统计信息
     * 
     * @param id 网格社区按社区维度统计ID
     * @return 结果
     */
    @Override
    public int deleteDataWgWgsqSqById(String id)
    {
        return dataWgWgsqSqMapper.deleteDataWgWgsqSqById(id);
    }

    /**
     * 查询所有汇总之和
     * @return
     */
    @Override
    public DataWgWgsqSq queryAllSqHz(DataWgWgsqSq dataWgWgsqSq,LoginUser userInfo) {
        //如果是admin用户不做处理
        if(userInfo.getRoles().contains("zhhz")){
            dataWgWgsqSq.setOrgId(userInfo.getSysUser().getDept().getOrgId());
        } else if(userInfo.getRoles().contains("common")){
            dataWgWgsqSq.setOrgId(userInfo.getSysUser().getDept().getOrgId());
            dataWgWgsqSq.setManagerId(userInfo.getSysUser().getUserName());
        }
        return dataWgWgsqSqMapper.queryAllSqHz(dataWgWgsqSq);
    }

    /**
     * 根据登陆用户查询社区概况
     * @param userInfo
     * @return
     */
    @Override
    public DataWgWgsqSq selectDataWgWgsqSqByUserInfo(DataWgWgsqSq dataWgWgsqSq,LoginUser userInfo) {
        //如果是admin用户不做处理
        if(userInfo.getRoles().contains("zhhz")){
            dataWgWgsqSq.setOrgId(userInfo.getSysUser().getDept().getOrgId());
        } else if(userInfo.getRoles().contains("common")){
            dataWgWgsqSq.setOrgId(userInfo.getSysUser().getDept().getOrgId());
            dataWgWgsqSq.setManagerId(userInfo.getSysUser().getUserName());
        }
        return dataWgWgsqSqMapper.selectDataWgWgsqSqByUserInfo(dataWgWgsqSq);
    }
}
